package com.woniu.mapper;

import com.woniu.dto.DrugDto;
import com.woniu.entity.Drug;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
* @author Administrator
* @description 针对表【drug(药品表)】的数据库操作Mapper
* @createDate 2025-11-01 17:01:11
* @Entity com.woniu.entity.Drug
*/
public interface DrugMapper {

    int deleteByPrimaryKey(Long id);

    int insert(Drug record);

    int insertSelective(Drug record);

    Drug selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Drug record);

    int updateByPrimaryKey(Drug record);

    List<Drug> findAll(DrugDto drugDto);
    Drug findByName(String drugName);

    // *** 1. 额外添加的新方法 (用于扣减库存) ***
    Integer decreaseStock(@Param("id") Integer id, @Param("quantity") Integer quantity);

    // *** 2. 额外添加的新方法 (用于事务中获取价格和名称) ***
    Drug findDrugForPrescription(Integer id);
}
